<?php
/*=============================================================================
|| ##################################################################
||	phpFoX Konsort
|| ##################################################################
||	
||	Copyright		: (C) 2005-2007 PHPFOX Limited a Reality Fox Creation
||	Contact			: info@phpfox.com
||
||	- phpFoX and all of its source code and files are protected by Copyright Laws. 
||
||	- The license for phpFoX permits you to install this software on a single domain (.com, .org, .net, etc.). 
||
||	- You may also not remove this copyright screen which shows the copyright information and credits for phpFoX (RealityFOX Creations). 
||
||	- phpFoX Konsort is NOT a FREE software - http://www.phpfox.com/license/
||
|| ##################################################################
=============================================================================*/

/* $File: ./include/modules/Messenger/classes/PhpFox_ComponentList.class.php, $Author:  $ */



/** List component
 * 
 * @package module.messenger
 * @version $Id: PhpFox_ComponentList.class.php 446 2008-04-30 08:42:40Z phpfoxsv $
 *   PHPFox Team ()
 */
class PhpFox_Mod_Messenger_ComponentList extends BaseComponent 
{
    function process()
    {
        $oReq = &App::getRequest();
        $oSrvAccount = &App::getModuleService('Account', 'Security');
        if($oReq->getInt('del'))
        {
            $oSrvMessenger = $this->_oModule->getService('Messenger');
            
            if($oSrvMessenger->delete($oReq->getInt('del')))
            {
                $oUrl = &App::getUrl();
        		$oUrl->setParam('del', null);
        		
        		App::gotoUrl(App::getPageName(), $oUrl->getParams(), App::format('Mod_Messenger.delete.item'), 'message', 'Messenger');
            }
            else
                App::addErrors($oSrvMessenger->getErrors());
        }
 
        $iPage = $oReq->get('page', 1);
        $iPageSize = App::getSetting('ADMIN_PAGESIZE', 10);
        
        $aCond = array();
        $sOrder = 'time DESC';
        
        $oSrvMessenger = $this->_oModule->getService('Messenger');

        list($aMessenger, $iCnt) = $oSrvMessenger->listMessages($aCond, $iPage, $iPageSize, $sOrder);
        $oPager = App::newObject('Pager', $iCnt, $iPage, $iPageSize);
        
        $oTpl = &$this->_oModule->getTemplate();
        
        $oTpl->assign(array(
            'aParams' => $this->_aParams,
            'aMessenger'   => $aMessenger,
            'aPaging' => $oPager->getInfo(App::getUrl())
        ));
  
        $sHtml = $oTpl->fetch('List.html');
        
        return $sHtml;
    }
}
?>